from flask_sqlalchemy import SQLAlchemy
import time

db = SQLAlchemy()


def get_time():
    return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))


def to_json_all(msg: list):
    data = []
    if type(msg) == list:
        for i in range(len(msg)):
            temp_dict = {}
            j = 0
            for k, v in msg[i].__dict__.items():
                if j > 0:
                    temp_dict[k] = v
                j += 1

            data.append(temp_dict)
    else:
        temp_dict = {}
        j = 0
        for k, v in msg.__dict__.items():
            if j > 0:
                temp_dict[k] = v
            j += 1
        data = temp_dict
    return data


if __name__ == "__main__":
    print(get_time())
